<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 
        Object.defineProperty():给某个对象扩展具有描述属性的属性,或者给对象添加存取器属性
      */

      const obj = {
        a: 1,
        b: 2,
      };

      Object.defineProperty(obj, "c", {
        value: 3,
        writable: false, //不可修改
        enumerable: false, //不可被枚举
        configurable: false,//不可被删除
      });

      obj.c = 4;
      console.log(obj);

      for (const key in obj) {
        console.log(key);
      }

      delete obj.c;

      console.log(obj);
    </script>
  </body>
</html>
